<?php
defined('BASEPATH') OR exit('No direct script access allowed');
header("Content-type: text/html; charset=utf-8");
class Php extends CI_Controller{
//    var $login_user;
    function __construct(){
        parent::__construct();
        $this->load->helper('cookie');
    }
    function check_login() {
        $this->login_user = bwc_user_login_get();
    }
    function display($view, $data = []) {
        $this->load->view('home/'.$view,$data);
    }
    function index($is_json = 0){
        $offset = get_parameter('offset', 0, 'get');
        $data['base_url'] = site_url('php/index/1').'?1=1';
        $list = db_get_list('article', 'cid=2 and state=1', 10, $offset, 'id desc');
        $data['list'] = $list;
        $data['xcid'] = 2;
        if ($is_json == 1) {
            if( count($list) > 0 ) {
                $this->display('article_item', $data);
            } else {
                echo 0;
            }
        } else {
            $data['rec'] = db_get_list('article', ['cid' => 2, 'is_rec' => 1, 'state' => 1], 10, '', 'id desc');
            $data['dj'] = db_get_list('article', ['cid' => 2, 'state' => 1], 10, '', 'view desc');
            $this->display('php', $data);
        }
    }
}
